//导入工具类
import request from "@/utils/request";

//查询所有企业地址
export const getAllAddress = (pageNum,pageSize,keyword) =>{
    return request.get(`/address/page?pageNum=${pageNum}&pageSize=${pageSize}&keyWord=${keyword}`);
}

//根据id查询企业
export const getCompanyById = (companyId) =>{
    return request.get(`/company/${companyId}`);
}

//查询总页数
export const getAllPage = (keyword) =>{
    return request.get(`/address/count?keyWord=${keyword}`);
}

//删除企业地址
export const deleAddress = (addressName) =>{
    return request.delete(`/address/deleteByName/${addressName}`);
}

//增加企业地址
export const address = (data) =>{
    if(data.oldAddressName == ""){
        console.log("aaaaaaaa",data);
        let address = {
            companyId:data.companyId,
            addressName:data.addressName,
            tip:0
        }
        return request.post("/address/add/",address);
    }else{
        console.log("bbbbbbbb",data);
        let address = {
            companyId:data.companyId,
            addressName:data.addressName,
            tip:0
        }
        return request.post(`/address/update?oldAddressName=${data.oldAddressName}`,address);
    }
}

//查询总企业数
export const getAllCompany = () =>{
    return request.get("/company/count");
}